import {
  app,
  Menu,
  globalShortcut,
  BrowserWindow
} from "electron";


import MainWindow from "./main/win/mainWin";

import HTray from "./main/tray";
const path = require("path");



Menu.setApplicationMenu(null);

async function initApp() {
  global.app = app;
  global.appId = "Nic586800";
  global.processId = "12w45";


  if (process.platform === "darwin") {
    app.setAboutPanelOptions({
      applicationName: "前端大狗",
      version: "1.0",
      copyright: "auto",
      authors: ["Nicnic"]
    });
  }

  // 登录窗口
  // app.loginWindow = new LoginWindow();
  // app.loginWindow.show();
  // 主窗口
  app.mainWindow = new MainWindow();
  app.mainWindow.show();
  // 共通窗口
  // app.commonWindow = new CommonWindow();
  // 托盘
  app.tray = new HTray();
  app.tray.show();

  globalShortcut.register('CommandOrControl+Shift+i', function () {
    app.mainWindow.openDevTools()
  })
  // 快捷键
  // global.shortcut = new HTShortcut();

  // console.log("im server addr:", env.API_ENDPOINT);
  // console.log("push server addr:", env.PUSH_IP, env.PUSH_PORT);
}


app.on('ready', () => {
  initApp();
});

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  // if (mainWindow === null) {
  //   createWindow();
  // }
});
